package offer.offer02;

/**
 * 100, 100, 这种递归就比较简单。
 */
public class Solution28 {
    public boolean isSymmetric(TreeNode root) {
        if(root == null) return true;
        return subIsSymmetric(root.left, root.right);
    }
    public boolean subIsSymmetric(TreeNode left, TreeNode right){
        if(left == null && right == null) return true;
        if((left == null & right != null) || (left != null & right == null)) return false;
        if(left.val == right.val){
            return subIsSymmetric(left.left, right.right) && subIsSymmetric(left.right, right.left);
        }else {
            return false;
        }
    }
}
